/*
 * BanBu_AlbumPreviewCell
 * @description 本文件提供个人空间相册预览或其他用户的相册浏览部分
 * @package
 * @author 		yinlinlin
 * @copyright
 * @version 		1.0
 * @description 本文件提供个人空间相册预览或其他用户的相册浏览部分
 */


#import "BanBu_AlbumPreviewCell.h"

@implementation BanBu_AlbumPreviewCell
@synthesize coverImgV = _coverImgV;

- (void)dealloc
{
    _coverImgV = nil;
//    _numLabel = nil;
    _titleLabel = nil;
    _albumType = nil;
    [super dealloc];
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];
        // Initialization code
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        UIImageView * backImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 17, 320, 278)];
        backImg.image = [UIImage imageNamed:@"album_previewBack.png"];
        [self.contentView addSubview:backImg];
        [backImg release];
        
        _coverImgV = [[UIImageView alloc]initWithFrame:CGRectMake(4.5, 55, 311, 208)];
        [self.contentView addSubview:_coverImgV];
        [_coverImgV release];
        
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 28, 200, 18)];
        _titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = UIColorWithRGB(94, 94, 94, 1.0);
        [self.contentView addSubview:_titleLabel];
        [_titleLabel release];
        
        _albumType = [[UILabel alloc]initWithFrame:CGRectMake(100, 268, 205, 18)];
        _albumType.font = [UIFont boldSystemFontOfSize:15.0];
        _albumType.textAlignment = kTextAlignmentRight;
        _albumType.textColor = UIColorWithRGB(94, 94, 94, 1.0);
        _albumType.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:_albumType];
        [_albumType release];
    }
    return self;
}
- (void)updateCellData:(BanBu_AlbumModel *)album_model
{
    _titleLabel.text = [NSString stringWithFormat:@"%@  %d",album_model.album_title,album_model.numCount];
//    _numLabel.text = [NSString stringWithFormat:@"%d",album_model.numCount];
    if (album_model.album_type == ALBUM_SYSTEM)
    {
        _albumType.text = NSLocalizedString(@"property_system", nil);
        if ([album_model.album_id isEqualToString:Album_privacy])
        {
            //2014年10月11日15:24:41 by yinlinlin 修改私密相册不使用url，直接显示私密默认图片
            [_coverImgV setImage:[UIImage imageNamed:@"cover_privacy.png"]];
        }
        else
        {
            //            _coverImgV.image = [UIImage imageNamed:@"cover_encryption.png"];
            [_coverImgV setImageWithURL:[NSURL URLWithString:album_model.image_url] placeholderImage:[UIImage imageNamed:@"cover_public.png"] andType:0];
        }
    }
    else
    {
        switch (album_model.personalbum_type) {
            case CREATE_PUBLIC:
            {
                _albumType.text = NSLocalizedString(@"property_public", nil);
                //                _coverImgV.image = [UIImage imageNamed:@"cover_encryption.png"];
                [_coverImgV setImageWithURL:[NSURL URLWithString:album_model.image_url] placeholderImage:[UIImage imageNamed:@"cover_public.png"] andType:0];
                break;
            }
            case CREATE_PRIVATE:
            {
                _albumType.text = NSLocalizedString(@"property_privacy", nil);
                //                _coverImgV.image = [UIImage imageNamed:@"cover_encryption.png"];
                [_coverImgV setImageWithURL:[NSURL URLWithString:album_model.image_url] placeholderImage:[UIImage imageNamed:@"cover_privacy.png"] andType:0];
                break;
            }
                
            case CREATE_QUESSTION:
            {
                _albumType.text =NSLocalizedString(@"property_encryption", nil);
                _coverImgV.image = [UIImage imageNamed:@"cover_encryption.png"];
                break;
            }
                
            case CREATE_OPENGROUP:
            {
                _albumType.text = NSLocalizedString(@"property_designess", nil);
                //                _coverImgV.image = [UIImage imageNamed:@"cover_encryption.png"];
                [_coverImgV setImageWithURL:[NSURL URLWithString:album_model.image_url] placeholderImage:[UIImage imageNamed:@"cover_public.png"] andType:0];
                break;
            }
                
            default:
            {
                _albumType.text = NSLocalizedString(@"property_notdesigness", nil);
                [_coverImgV setImageWithURL:[NSURL URLWithString:album_model.image_url] placeholderImage:[UIImage imageNamed:@"cover_public.png"] andType:0];
                break;
            }
        }
    }
    
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
